home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-24 | 1.7 KB | 69 lines | [TEXT/PJMM] |
- PROGRAM MusicTest;
- USES
- Components, Music;
-
- VAR
- h: MusicDescriptionHandle;
- tp: TunePlayer;
- result: ComponentResult;
- theTuneStatus: TuneStatus;
- err: OSErr;
-
- LABEL
- 10; { used for error cleanup }
- BEGIN
- { Get the music resource and lock it down }
- h := MusicDescriptionHandle(GetResource('Musi', 128));
- IF h = NIL THEN
- ExitToShell;
- HLock(Handle(h));
-
- { open the default tune player }
- tp := OpenDefaultComponent(kTunePlayerType, ResType(LongInt(kAnyComponentType)));
- IF tp = NIL THEN
- ExitToShell;
-
- { tell that we have 600 units per second }
- result := TuneSetTimeScale(tp, 600);
- IF result <> noErr THEN
- GOTO 10;
-
- { Set the header, to tell what instruments are used }
- result := TuneSetHeader(tp, @h^^.headerData);
- IF result <> noErr THEN
- GOTO 10;
-
- { Have it allocate whatever resources are needed }
- result := TunePreRoll(tp);
- IF result <> noErr THEN
- GOTO 10;
-
- { We want to play at normal volume }
- result := TuneSetVolume(tp, $10000);
- IF result <> noErr THEN
- GOTO 10;
-
- { Queue up the music, normal tempo, play everything now }
- result := TuneQueue(tp, Pointer(ORD4(h^) + h^^.size), $10000, 0, $7FFFFFFF, kTuneStartNow, NIL, 0);
- IF result <> noErr THEN
- GOTO 10;
-
- REPEAT
- result := TuneGetStatus(tp, theTuneStatus);
- IF result <> noErr THEN
- GOTO 10;
- { spin until we click the button or no music left queued up }
- UNTIL Button | (theTuneStatus.queueCount = 0);
-
- { We get here either by getting an error or having everything finish }
- { Regardless, we need to stop and clean up everything }
- 10:
- IF result <> noErr THEN
- DebugStr('Music result');
- IF tp <> NIL THEN
- result := TuneStop(tp, kStopFadeout);
- IF tp <> NIL THEN
- err := CloseComponent(tp);
-
- { And we are done }
- END.